<template>
	<view
		class="page"
		style="background-image: url('https://www.shlxkj.info:10010/%E5%81%A5%E5%BA%B7%E6%A1%A3%E6%A1%88/zsafimg/bgimg.png'); background-size: cover; background-repeat: no-repeat"
	>
		<view class="avatar">
			<image src="/static/image/avatar.png" mode="aspectFit"></image>
		</view>
		<view class="username">{{ username }}</view>
		<view class="content">
		<!-- 	<view class="item-wrap" @click="goHelp">
				<view class="icon-wrap">
					<image class="icon" src="/static/image/help.png" mode="widthFix"></image>
				</view>
				<view class="item">
					<text class="desc">使用帮助</text>
					<image class="arrow" src="/static/image/right.png" mode="widthFix"></image>
				</view>
			</view>
			<view class="item-wrap" @click="goAgreement">
				<view class="icon-wrap">
					<image class="icon" src="/static/image/agreement.png" mode="widthFix"></image>
				</view>
				<view class="item">
					<text class="desc">用户协议</text>
					<image class="arrow" src="/static/image/right.png" mode="widthFix"></image>
				</view>
			</view>
			<view class="item-wrap" @click="goPrivacy">
				<view class="icon-wrap">
					<image class="icon" src="/static/image/privacy.png" mode="widthFix"></image>
				</view>
				<view class="item">
					<text class="desc">隐私政策</text>
					<image class="arrow" src="/static/image/right.png" mode="widthFix"></image>
				</view>
			</view> -->
			<!-- 		<view class="item-wrap" @click="updateVersion">
				<view class="icon-wrap">
					<image class="icon" src="/static/image/agreement.png" mode="widthFix"></image>
				</view>
				<view class="item">
					<text class="desc">当前版本日期: {{versionCode}}</text>
				</view>
			</view> -->
			<!-- <view class="item-wrap">
				<view class="icon-wrap">
					<image class="icon" src="/static/image/agreement.png" mode="widthFix"></image>
				</view>
				<view class="item">
					<text class="desc">最新版本日期: {{newVersionCode}}</text>
				</view>
			</view> -->
			<view class="item-wrap" @click="logOut">
				<view class="icon-wrap">
					<image class="icon" src="/static/image/logout.png" mode="widthFix"></image>
				</view>
				<view class="item">
					<text class="desc">退出登录</text>
					<image class="arrow" src="/static/image/right.png" mode="widthFix"></image>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
import { FindLoginUser } from '../../utils/api';

export default {
	name: 'UserCenter',
	data() {
		return {
			username: '',
			versionCode: '',
			newVersionCode: ''
		};
	},
	onShow() {},
	onLoad(op) {
		this.FindLoginUser();
	},
	methods: {
		// 获取当前账号信息
		async FindLoginUser() {
			const res = await FindLoginUser();
			console.log(res.data);
			this.username = res.data.admininfo.name;
		},
		goHelp() {
			uni.navigateTo({
				url: '/pages/help/index'
			});
		},
		goAgreement() {
			uni.navigateTo({
				url: '/pages/agreement/index'
			});
		},
		goPrivacy() {
			uni.navigateTo({
				url: '/pages/privacy/index'
			});
		},
		logOut() {
			uni.showModal({
				title: '提示', // 弹窗标题
				content: '确认退出当前账号吗?', // 弹窗内容
				success: (res)=>{
					if (res.confirm) {
						console.log(this.$store.state);
						this.$store.commit('$uStore', {
							name: 'vx_token',
							value: ''
						});
						console.log(this.$store.state);
						uni.navigateTo({
							url: '/pages/login/index'
						});
					} else if (res.cancel) {
						console.log('用户点击取消');
					}
				}
			});
		}
	}
};
</script>

<style lang="scss" scoped>
.page {
	width: 100%;
	height: 100vh;
	position: relative;
	// background-image: url('/static/image/bgimg.png');
	// background-size: cover;
	// background-repeat: no-repeat;
	overflow: hidden;

	.avatar {
		margin: 200rpx auto 0;
		width: 155rpx;
		height: 155rpx;
		image {
			width: 100%;
			height: 100%;
		}
	}
	.username {
		width: 100%;
		text-align: center;
		margin-top: 30rpx;
		font-weight: 500;
		font-size: 35rpx;
		color: #222222;
		line-height: 41rpx;
	}
}

.content {
	position: relative;
	width: 92%;
	margin: 90rpx auto 0;
	padding: 0 32rpx 15rpx;
	box-sizing: border-box;
	background: #ffffff;
	border-radius: 23rpx 23rpx 23rpx 23rpx;

	.item-wrap {
		line-height: 103rpx;
		display: flex;
		justify-content: space-between;
		align-content: center;

		.icon-wrap {
			width: 103rpx;
			height: 103rpx;
			display: flex;
			justify-content: center;
			align-items: center;
		}

		.icon {
			width: 38rpx;
			height: 38rpx;
		}

		.item {
			line-height: 103rpx;
			flex: 1;
			display: flex;
			justify-content: space-between;
			align-items: center;
			// border-bottom: 1rpx solid rgba(0, 0, 0, 0.05);
			font-weight: 500;
			font-size: 32rpx;
			color: #222222;
			line-height: 32rpx;

			.arrow {
				width: 30rpx;
				margin-right: 10rpx;
			}
		}
	}
}

.entry {
	.title {
		width: 100%;
		text-align: center;
		color: black;
		font-size: 20px;
		padding-bottom: 20rpx;
	}

	.intxt1,
	.intxt2 {
		background-color: #f5f5f5;
		height: 80rpx;
		line-height: 80rpx;
		margin-bottom: 20rpx;
	}
}
</style>
